package com.chinaoryx;

import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * Servlet implementation class TaskListServlet
 */
public class TaskListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;


//    static {
//        ExecutorService es = Executors.newCachedThreadPool();
//        Future f1 = es.submit(new MyThread("1", 1000*2));
//        Future f2 = es.submit(new MyThread("2", 1000*2));
//
//
//
//    }

    /**
     * Default constructor. 
     */
    public TaskListServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        ThreadFactory factory = ThreadFactory.newInstance();
        List<TaskObject> list = factory.getTaskList();
        request.setAttribute("taskList", list);
        RequestDispatcher dispatcher = request.getRequestDispatcher("/list.jsp") ;
        dispatcher.forward(request,response);
//		Writer out = response.getWriter();
//		out.write("My Test");
//		out.flush();
//		return;
		// TODO Auto-generated method stub
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
